home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / vopl / glvopl.lha / glvopl / examples / fex2.F < prev    next >
Encoding:
Text File  |  1993-10-07  |  2.3 KB  |  141 lines

  1. c
  2. c    Another very simple test program for vopl.
  3. c
  4. c     This one also draws a graph of y = sin(x) 0 <= x <= 2*pi
  5. c    but shows some of the axis and range setting stuff
  6. c
  7.     program test1
  8. #ifdef SGI_GL
  9. #include "fgl.h"
  10. #include "fdevice.h"
  11. #else
  12. #include "fvogl.h"
  13. #include "fvodevice.h"
  14. #endif
  15.  
  16.     parameter (pi = 3.14159265358979)
  17.     parameter (n = 300)
  18.  
  19.     real x(n), y(n)
  20.  
  21.     integer *2 val, left, right, bottom, top
  22. c
  23. c    Generate the points
  24. c
  25.     t = 0.0
  26.     dt = 2 * pi / n
  27.  
  28.     do 10 i = 1, n
  29.         x(i) = t
  30.         y(i) = sin(t)
  31.         t = t + dt
  32. 10    continue
  33.  
  34. c
  35. c    Set the X-scaling to be absolute 0 - 10 (ie no auto-scaling)
  36. c
  37.     call range(0.0, 10.0, 'x')
  38. c
  39. c    Autoscale the Y-axis
  40. c
  41.     call adjustscale(y, n, 'y')
  42. c
  43. c    Anyone for some axis titles?
  44. c
  45.     call axistitle('This one''s for you', 'x')
  46.     call axistitle('This one''s for me', 'y')
  47. c
  48. c    As we are now about to do some graphics we initialise VOGLE
  49. c    and clear to BLACK
  50. c
  51.     call hfont('futura.l', 8)
  52.     call winope('VOPL', 4)
  53.     call qdevic(KEYBD)
  54.     call color(0)
  55.     call clear
  56. c
  57. c    Now set the color to GREEN
  58. c
  59.     call color(2)
  60.  
  61. c
  62. c    Draw the default set of axes (in GREEN)
  63. c
  64.     call drawaxes2
  65. c
  66. c    Set color to RED
  67. c
  68.     call color(1)
  69. c
  70. c    Draw the Graph
  71. c
  72.     call plot2(x, y, n)
  73. c
  74. c    Wait around a bit
  75. c
  76.     idum = qread(val)
  77. c
  78. c    Now draw a little one in the top right hand corner
  79. c    by reseting the VOGL viewport.
  80. c
  81.         call getvie(left, right, bottom, top)
  82. c
  83. c       Now assign them to integer *4 variables (thanks SGI!)
  84. c
  85.     minx = left
  86.     maxx = right
  87.     miny = bottom
  88.     maxy = top
  89.     call viewpo((minx + maxx) / 2, maxx, (maxy + miny) / 2, maxy)
  90. c
  91. c    Draw it again, but do the plot first (in BLUE) then the axes
  92. c    (in YELLOW)
  93. c
  94.     call color(4)
  95.     call plot2(x, y, n)
  96.     call color(3)
  97.     call drawaxes2
  98. c
  99. c    Hang around again
  100. c
  101.     idum = qread(val)
  102. c
  103. c    Clear it all away
  104. c
  105.         call viewpo(minx, maxx, miny, maxy)
  106.     call color(0)
  107.     call clear
  108. c
  109. c    Reset the viewport to be a "long skinny one"
  110. c
  111. c
  112.         call viewpo(minx, maxx, 
  113.      +        miny + (maxy + miny) / 3, maxy - (maxy + miny)/ 3)
  114.  
  115. c    Autoscale the X-axis again by first setting a ridicuous scale with
  116. c    range that adjustscale will change.
  117. c
  118.     call range(1000.0, -1000.0, 'x')
  119.     call adjustscale(x, n, 'x')
  120. c
  121. c    Change the X-axis title
  122. c
  123.     call axistitle('Blark Bonk Bloot', 'x')
  124. c
  125. c    And draw it all again...
  126. c
  127.     call color(5)
  128.     call drawaxes2
  129.     call color(6)
  130.     call plot2(x, y, n)
  131. c
  132. c    Hang around again
  133. c
  134.     idum = qread(val)
  135. c
  136. c    Bugger off...
  137. c
  138.  
  139.     call gexit
  140.     end
  141.